import { Helper } from "@/core/helper/helper.service";
import { DrawerProps, ElDrawer } from "element-plus";
import { Component, ComputedOptions, MethodOptions } from "vue";
import { Base, PopOption } from "./base";
export type TDrawerOption = PopOption<DrawerProps>;
export class Drawer extends Base<DrawerProps> {
  protected getPop(): Component<any, any, any, ComputedOptions, MethodOptions> {
    return ElDrawer;
  }
  constructor(option: TDrawerOption, stc?: boolean) {
    super(option, stc);
  }

  protected closePop(destory: boolean) {
    if (this.comp?.component) {
      const { handleClose, drawerRef } = this.comp?.component?.proxy || {};
      if (handleClose) {
        handleClose();
      }
      if (destory || this.noStc) {
        setTimeout(() => {
          (drawerRef as HTMLElement).parentElement?.parentElement.remove();
          Helper.staticDrawers = null;
        }, 1000);
      }
    }
  }
}
